<?php

require_once ('BaseAjaxModule.php');

class AgentModule extends BaseAjaxModule {
	
	public function getAgentsTask()	{
		$agent_info = Model_Config::getAgentInfo();
		$agents = Model_Agent::getAllAgents();
		$agents_bac = array();
		$agents_trung = array();
		$agents_nam = array();
		foreach($agents as $agent){
			if($agent->region == 1) $agents_bac[] = $agent;
			else if($agent->region == 2) $agents_trung[] = $agent;
			else if($agent->region == 3) $agents_nam[] = $agent;
		}
		$this->view->result = array('agent_info'=>$agent_info,'agents_bac'=>$agents_bac, 'agents_trung'=>$agents_trung, 'agents_nam'=>$agents_nam);
	}
	
	public function getAgentDetailTask(){
		$agent = new Model_Agent();
		$agent->id = $this->getParam('id');
		$agent->connect();
		$this->view->result = $agent->getAgentDetail();
	}
}

?>